package com.sky.wsp.kafka.controller;

import com.sky.wsp.kafka.producer.KafkaMessageProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author wangshaopeng@talkweb.com.cn
 * @desccription 在此输入描述
 * @date 2024/5/24
 */
@RestController
public class IndexController {
    Logger log = LoggerFactory.getLogger(IndexController.class);
    @Resource
    private KafkaMessageProducer kafkaMessageProducer;

    @GetMapping
    public String index(String msg) {
        if (null == msg || "".equals(msg.trim())) {
            msg = "生成随机消息" + UUID.randomUUID();
        }
        log.info("发送消息：{}", msg);
        kafkaMessageProducer.sendAdminMessage(msg);
        return "消息已发送，请查看控制台日志: " + msg;
    }
}

